import React, { Component } from 'react'
import { Button } from 'antd';

// 引入store,用于获取redux中保存的状态
import store from '../../redux/store';

export default class Count extends Component {

    //加法
    increment = () => {
        let { value } = this.selectNumber;
        this.props.increment(value*1);
    }
    // 减法
    decrement = () => {
        let { value } = this.selectNumber;
        this.props.decrement(value*1);
    }
    // 异步减法
    syncDecrement = () => {
        let { value } = this.selectNumber;
        this.props.syncDecrement(value*1,500);
    }
    render() {
        console.log(this.props);
        let { count } = this.props;
        return (
            <div>
                <h1>当前求和为：{ count }</h1>
                &nbsp;<select ref={(c)=>{this.selectNumber = c}}>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                </select>&nbsp;
                <Button onClick={this.increment} type="primary">加</Button>&nbsp;
                <Button onClick={this.decrement} type="primary">减</Button>&nbsp;
                <Button onClick={this.syncDecrement} type="primary">异步减</Button>
            </div>
        )
    }
}
